package com.objectdraw.client.objectdraw;

import javax.swing.*;

/**
 * creates a tool bar to hold the toggle buttons for selecting tools
 * @author jgulik, cfruehan
 *
 */
@SuppressWarnings("serial")
public class ToolBar extends Box {
  
	/**
	 * takes the provided list of tools and adds them to a set of toggle buttons.
	 * 
	 * @param actions list of tools
	 */
  ToolBar(ToolList actions) {
    super(BoxLayout.Y_AXIS);
    ToolListIterator iter = actions.iterator();
    ButtonGroup group = new ButtonGroup();
    while(iter.hasNext()) {
      Action a = (Action) iter.next();
      JToggleButton button = new JToggleButton((Icon) a.getValue(Action.SMALL_ICON));
      button.setToolTipText((String) a.getValue(Action.SHORT_DESCRIPTION));
      button.addActionListener(a);
      group.add(button);
      add(button);
    }
    
    add(Box.createVerticalGlue());
  }
} 
